#include<iostream>
#include<vector>
#include<string>

class Solution {
public:
    int removeElement(std::vector<int>& nums, int val) {
        int k = 0; // k 记录不等于 val 的元素数量
        for (int i = 0; i < nums.size(); ++i) {
            if (nums[i] != val) {
                nums[k] = nums[i];
                k++;
            }
        }
        return k;
    }
};


int main(int argc, char* argv[]) {
    Solution solution;
    std::vector<int> nums = {3, 2, 2, 3};
    int val = 3;
    int result = solution.removeElement(nums, val);
    std::cout << "Result: " << result << std::endl;
    return 0;
}